
/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/hoteleria/temporadas>} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"29AA8A71-32D3-469C-9300-C29918442D43"}
 */
function onTemporadasRecordInsert(record) {
	record.cant_dias = globals.diferenciaDias(record.fecha_final,record.fecha_inicial)
	var $ff = record.fecha_final
	record.fecha_final = new Date($ff.getFullYear(), $ff.getMonth(), $ff.getDate(),23,59,59,996)
	return true
}

/**
 * Record pre-update trigger.
 * Validate the record to be updated.
 * When false is returned the record will not be updated in the database.
 * When an exception is thrown the record will also not be updated in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/hoteleria/temporadas>} record record that will be updated
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"79844145-ADE8-44FB-B549-4187AF5BABE5"}
 */
function onTemporadasRecordUpdate(record) {
	record.cant_dias = globals.diferenciaDias(record.fecha_final,record.fecha_inicial)
	var $ff = record.fecha_final
	record.fecha_final = new Date($ff.getFullYear(), $ff.getMonth(), $ff.getDate(),23,59,59,996)
	return true
}
